<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>表单数据的计算属性</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
    <div id="应用"></div>
</body>
<script>
    const {createApp: 创建, ref: 引用, computed: 计算} = Vue 

    const 根组件 = {
        template: `
            <input v-model="姓" placeholder="姓"/>
            <input v-model="名" placeholder="名"/>
            <p>姓名: {{姓名}}</p>
        `,
        setup() {
            const 姓 = 引用('')
            const 名 = 引用('')
            const 姓名 = 计算(() => 姓.value + 名.value)

            return {姓, 名, 姓名}
        }
    }

    const 应用 = 创建(根组件)
    应用.mount('#应用')
</script>
</html>